/*
 * @Author: 姚潘涛
 * @Date: 2024-04-08 20:36:39
 * @LastEditors: 姚潘涛
 * @LastEditTime: 2024-04-10 15:47:01
 * @FilePath:
 * /xict_ws/src/xcmg-intelligent-cockpit-three/src/xict_ui/include/xict_ui_common/utils/config.h
 * @Description:
 *
 * Copyright (c) 2024 by pandaman, All Rights Reserved.
 */
#ifndef CONFIG_H
#define CONFIG_H

#include "yaml-cpp/yaml.h"
#include <QDebug>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QSettings>
#include <QVariant>

namespace xict_ui_common {

    class Config {
    protected:
        Config() { }

    public:
        static Config& GetInstance() {
            static Config demo;
            return demo;
        }

        Config(const Config&) = delete;
        Config& operator=(const Config&) = delete;

        bool Init(const QString& cfg_path);
        void Set(QString, QString, QVariant);
        QVariant GetCfg(QString, QString);
        std::string GetYaml(QString, QString);
        bool GetJsonArray(const QString& json_path, QJsonArray& out_array);
        bool GetYamlArray(const QString& yaml_path, QJsonArray& out_array);

    private:
        QSettings* m_psetting;
        YAML::Node m_config;
    };
}   // namespace xict_ui_common

#endif   // CONFIG_H
